package com.qrxl.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qrxl.user.entity.Menu;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单 Mapper 接口
 * </p>
 *
 * @author friday
 * @since 2020-12-05
 */
public interface MenuMapper extends BaseMapper<Menu> {

    /**
     * 查询用户关联的角色
     *
     * @param loginId
     * @return
     */
    @Select("SELECT id,name,url,menu_icon,parent_id FROM menu WHERE id in(SELECT menu_id FROM role_menu WHERE role_id in (SELECT role_id FROM user_role WHERE user_id=${loginId}))")
    List<Menu> qeryUserMenus(String loginId);
}
